<cfparam name = "showfolders" default="0">
<cfset user #cookie.account_username#>
<cfif NOT directoryexists('#request.downloadspath##user#')>
	<cfdirectory action="create" directory="#request.downloadspath##user#">
</cfif>
<cfset dir = "/#user#/">
<cfset fullpath = "#request.downloadspath##dir#">
<cfset fullpath = replacenocase(FullPath, "//", "/", "ALL")>
<cfset dir = replacenocase(dir, "//", "/", "ALL")>
<cfinvoke component="cfcs.admin.filemanager" method="getfiles" fullpath="#fullpath#" returnvariable="qfiles" />
<cfinvoke component="cfcs.admin.filemanager" method="getfolders" fullpath="#fullpath#" returnvariable="qfolders" />
<h2><cfoutput>#request.lang.accounts.downloads.title#</cfoutput></h2>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<cfoutput>
    <tr>
      <td id="columnheaders"></td>
      <td id="columnheaders">#request.lang.accounts.downloads.col2#</td>
      <td id="columnheaders">#request.lang.accounts.downloads.col3#</td>
      <td id="columnheaders">#request.lang.accounts.downloads.col4#</td>
      <td id="columnheaders">&nbsp;</td>
    </tr>
    <!---if it's not the main folder then list the files--->
    <form name = "filemanager" id="filemanager" action="index.cfm?c=accounts" method="Post">
    
      <cfloop query = "qfiles">
        <!---Figure out what action to use on this file from it's file type--->
        <cfset theaction = 'index.cfm?c=accounts&a=download&&dir=#dir#&filename=#name#'>
        <cfset theicon='document.png'>
        <cfset thetype='none'>
      <cfif Right(name, 4) IS '.gif' OR right(name, 4) IS '.jpg' OR right(name, 4) IS '.png' OR right(name, 4) IS 'jpeg'>
          <cfset theaction='index.cfm?c=accounts&a=viewimage&&dir=#dir#&filename=#name#'>
          <cfset theicon='image.png'>
          <cfset thetype='Image'>
      </cfif>
      <cfif Right(name, 4) IS '.cfm' OR right(name, 5) IS '.html' OR right(name, 4) IS '.txt' OR right(name, 4) IS '.asp' OR right(name, 4) IS '.cfm' OR right(name, 4) IS '.php' OR right(name, 4) IS '.htm'>
          <cfset theicon='document_html.png'>
          <cfset thetype='webpage'>
      </cfif>
      <cfif Right(name, 4) IS '.pdf'>
          <cfset theicon='document_pdf.png'>
          <cfset thetype='pdf'>
      </cfif>
      <cfif Right(name, 4) IS '.doc' OR Right(name, 5) IS '.docx'>
          <cfset theicon='document_word.png'>
          <cfset thetype='word'>
      </cfif>
      <cfif Right(name, 4) IS '.xls' OR Right(name, 5) IS '.xlsx'>
          <cfset theicon='document_excel.png'>
          <cfset thetype='excel'>
      </cfif>
      <cfif Right(name, 4) IS '.avi' OR right(name, 4) IS 'mov' OR right(name, 4) IS '.mpg' OR right(name, 4) IS '.wmv' OR right(name, 4) IS '.mp4'>
          <cfset theicon='movie.png'>
          <cfset thetype='video'>
      </cfif>
      <cfif Right(name, 4) IS '.swf' OR Right(name, 4) IS '.flv'>
          <cfset theicon='document_flash.png'>
          <cfset thetype='flash'>
      </cfif>
      <cfif Right(name, 4) IS '.csv' OR Right(name, 4) IS '.txt'>
          <cfset theicon='document.png'>
          <cfset thetype='datafile'>
      </cfif>
      <cfif Right(name, 4) IS '.css'>
          <cfset theicon='document_css.png'>
          <cfset thetype='datafile'>
      </cfif>
      <cfif Right(name, 3) IS '.js'>
          <cfset theicon='document_javascript.png'>
          <cfset thetype='datafile'>
      </cfif>        
      <cfif Right(name, 4) IS '.csv' OR Right(name, 4) IS '.txt'>
          <cfset theicon='document.png'>
          <cfset thetype='datafile'>
      </cfif>        
      <cfif Right(name, 4) IS '.mp3' OR Right(name, 4) IS '.rm' OR Right(name, 4) IS '.ram' OR Right(name, 4) IS '.aif' OR Right(name, 4) IS '.aiff' OR Right(name, 4) IS '.wav' OR Right(name, 4) IS '.wma'>
          <cfset theicon='document_audio.png'>
          <cfset thetype='datafile'>
      </cfif>        
      <cfif Right(name, 4) IS '.zip'>
          <cfset theicon='document_zip.png'>
          <cfset thetype='compressedfile'>
      </cfif>
      <cfif Right(name, 4) IS '.rar'>
          <cfset theicon='document_rar.png'>
          <cfset thetype='compressedfile'>
      </cfif>
        <!---Display the list of files and the appropriate icon next to it--->
        <cfset idname = replace(name, ".", "", "ALL")>
        <cfset idname = replace(idname, " ", "", "ALL")>
        <tr class="menu_row" onMouseOver="this.className = 'menu_row_over2';" onMouseOut="this.className = 'menu_row';">
          <td valign="middle" class="menu_cell" width="5%"><div class="checkbox" id="acheckbox">
              <input type="checkbox" name="selfiles" id="selfiles" value="#name#" />
            </div></td>
          <td valign="middle" class="menu_cell"><span id = "norename_#idName#" style="display: block;"> <img src="images/filetypes/#theicon#" align="absmiddle"> <a href="#theaction#">#Name#</a> </span> </td>
          <td width="50" class="menu_cell" valign="middle"><div align="left">
              <cfif Size LT 1000>
                <cfset mySize = #size#>
                #mySize# b
              </cfif>
              <cfif Size GT 999 AND Size LT 1000000>
                <cfset mySize = #Size# / 1000>
                #Round(mySize)# kb
              </cfif>
              <cfif Size GT 999999>
                <cfset mySize = #Size# / 1000000>
                #Round(MySize)# mb
              </cfif>
            </div></td>
          <td width="200" class="menu_cell">#dateformat(dateLastModified, "mm/dd/yyyy")# #timeformat(dateLastModified, "hh:mm tt")#</td>
          <td width="200" align="right" valign="middle" class="menu_cell"><div align="right"><a href = "index.cfm?c=accounts&a=download&&dir=#dir#&filename=#name#"><img src="images/icons/download.png" border="0" alt="Download File" title="Download File" /></a></div></td>
        </tr>
      </cfloop> 
        <input type = "hidden" value="#dir#" name="dir" id="dir">
        <input type = "hidden" value="" name="name" id="name">
        <input type = "hidden" value="" name="renameto" id="renameto" />
        <input type = "hidden" value="/" name="tofolder" id="tofolder">
        <input type = "hidden" value="RemoveFiles" name="a" id="the_action">
  </form>
      <cfif qfiles.recordcount IS 0>
        <tr>
          <td colspan="4"><div id="messages_info">#request.lang.accounts.downloads.nodownloads#</div></td>
        </tr>
      </cfif>
</cfoutput>      
</table>
<div id="dialog" style="display: none; font-size: 10pt;">
  <cfinclude template="#request.absoluteadminpath#dialogs/filemanager/selectfolder_move.cfm">
</div>
<div id="defaultdialog" style="display: none;"> <img src="/images/defaults/loading.gif" /> </div>